package com.kkb.controller;

import com.kkb.pojo.User;
import com.kkb.service.UserService;
import com.kkb.vo.LoginQueryVO;
import com.kkb.vo.ResultVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("user")
@ResponseBody
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "login", method = RequestMethod.GET)
    public ResultVO<User> login(LoginQueryVO vo) {
        int login = userService.login(vo);
        if (login == -1) {
            return new ResultVO<User>(201, "请检查用户名是否正确");
        } else if (login == -2) {
            return new ResultVO<User>(201, "请检查密码是否正确");
        } else if (login == -3) {
            return new ResultVO<User>(201, "请检查验证码是否正确");
        } else {
            return new ResultVO<User>();
        }
    }
}
